package com.mdx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdx.bean.ControlGoodsBean;
import com.mdx.service.IControlGoodsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 药剂器械
 */
@RestController
@RequestMapping("goods")
public class GoodsController {

    @Resource
    private IControlGoodsService controlGoodsService;

    //查询所有信息
    @RequestMapping("findAll")
    public IPage<ControlGoodsBean> findAll(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                           @RequestParam(value = "pageSize", defaultValue = "2") int pageSize){
        return controlGoodsService.findByItem(pageNO,pageSize,null,null,null);
    }

    //添加
    @RequestMapping("add")
    public String add(ControlGoodsBean controlGoodsBean){
        controlGoodsService.addGoods(controlGoodsBean);
        return "ok";
    }

    //模糊查询
    @RequestMapping("findByItem")
    public IPage<ControlGoodsBean> findByItem(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                              @RequestParam(value = "pageSize", defaultValue = "2") int pageSize,
                                              String cgName,String cgType,String goodsType){
        return controlGoodsService.findByItem(pageNO,pageSize,cgName,cgType,goodsType);
    }
}
